 <template>
  <div class="login-wrapper">
    <div class="custom-topHr"></div>

    <div class="logo-box">
      <img class="logo" src="@/assets/images/logo1.png">
    </div>
    <div class="login-box">
      <div class="input-item">
        <div class="lbl-box">
          <label for="txtUsername">手机号</label>
        </div>
        <div class="txt-box">
          <div class="val-box all">
            <input
              class="txt-input"
              id="txtUsername"
              name="username"
              type="text"
              placeholder="请输入手机号"
              value
              v-model="username"
            >
            <i class="icon iconfont icon-guanbi111 custom-Eicon"></i>
          </div>
        </div>
      </div>

      <div class="input-item">
        <div class="lbl-box">
          <label for="txtPassword">密 码</label>
        </div>
        <div class="txt-box">
          <div class="val-box partial">
            <input
              class="txt-input"
              id="txtPassword"
              name="password"
              type="password"
              placeholder="请输入密码"
              value
              v-model="password"
            >
            <i class="icon iconfont icon-guanbi111 custom-Eicon"></i>
          </div>
          <div class="fuc-box">
            <span class="custom-verHr">|</span>
            <router-link class="forget-btn" to="/login/forgetpw">忘记密码</router-link>
          </div>
        </div>
      </div>

      <div class="submit-box">
        <button class="submit-btn" v-on:click="login">提 交</button>
        
        <!-- <a class="msg-login" href="#">短信验证登录</a> -->

        <p class="privacy-txt">
          <span>登录即代表已经并同意</span>
          <a href="#">《还美医疗整形隐私政策》</a>
        </p>
      </div>
    </div>
  </div>
</template>
 
<script type="text/ecmascript-6">
import constant from "@/utils/constant.js";
// 引用API文件
import http from "@/utils/http.js";
export default {
  name: "index",
  data() {
    return {
      username: "",
      password: ""
    };
  },
  components: {},
  methods: {
    login() {
      let username = this.username;
      let password = this.password;

      if (username == "" || password == "") {
        this.$message({
          message: "请填写用户名或密码",
          type: "warning"
        });
      } else {
        http.post(this, {
          url: "passport/adminlogin",
          data: {
            username: this.username,
            password: this.password
          },
          dataType: "json",
          success: function(data) {
            console.log("登录:", data);
            if (data.status == 1) {
              let user_info = data.info;
              localStorage.setItem("user_name", user_info.username);
              localStorage.setItem("user_token", user_info.token);
              localStorage.setItem("user_type", user_info.user_type);
              this.$router.push({
                //核心语句
                path: "/center"
              });
            } else {
              this.$message.error(data.info);
            }
          }
        });
      }
    }
  }
};
</script>
 
 <style scoped lang="scss">
</style>
 